<template>
  <div>
    <h1 :style="{opacity}">你好，我是彭于晏</h1>
    <ul>
      <li>news001 <input type="text"></li>
      <li>news002 <input type="text"></li>
      <li>news003 <input type="text"></li>
    </ul>
  </div>
</template>

<script>
export default {
  name: "my-news",
  data() {
    return{
      opacity:1
    }
  },
  activated() {
    //在组件被激活时调用
    this.timer = setInterval(() => {
      if (this.opacity <= 0) {
        this.opacity = 1;
      }
      this.opacity -= 0.01;
    },16)
  },
  deactivated() {
    //在组件失活时调用
    clearInterval(this.timer);
  }
}
</script>

<style scoped>

</style>